//
//  UIBarButtonItem+NavicationBar.m
//  ChatOnLine
//
//  Created by dllo on 16/8/11.
//  Copyright © 2016年 WWT. All rights reserved.
//

#import "UIBarButtonItem+NavicationBar.h"

@implementation UIBarButtonItem (NavicationBar)

+ (instancetype)itemWithImage:(NSString *)image hightImage:(NSString *)hightImage target:(id)target action:(SEL)action
{
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn setImage:[UIImage imageNamed:image] forState:UIControlStateNormal];
    [btn setImage:[UIImage imageNamed:hightImage] forState:UIControlStateHighlighted];
    [btn addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    [btn sizeToFit];
    //[self alloc]initWithCustomView:
    //              ||
    //[UIBarButtonItem alloc]initWithCustomView:
    //给按钮添加一个背景图片 防止点击范围越界
    UIView *containView = [[UIView alloc]initWithFrame:btn.bounds];
    [containView addSubview:btn];
    
    return [[self alloc]initWithCustomView:containView];
}

@end
